//
//  DoctorAddressTableViewCell.m
//  QuickCure1
//
//  Created by summer的Dad on 16/11/2.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "DoctorAddressTableViewCell.h"
#import "DoctorApplyListModel.h"
@interface DoctorAddressTableViewCell ()

@property(nonatomic,weak)UILabel* doctor_hospital_name;

@property(nonatomic,weak)UIButton* btn_hosptal_name;

@end

@implementation DoctorAddressTableViewCell

#pragma mark
#pragma mark - 入口
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
    
}

-(void)setModel:(DoctorApplyListModel *)model
{
    _model = model;
   
    self.doctor_hospital_name.text = model.doctor_hospital_name;
    [self.btn_hosptal_name setTitle:model.doctor_hospital_name forState:UIControlStateNormal];
}

#pragma mark
#pragma mark - 搭建界面
- (void)setupUI
{
    
    //title
    UILabel* leble_title = [[UILabel alloc] init];
    leble_title.text = @"就诊地点:";
    [leble_title sizeToFit];
    [self.contentView addSubview:leble_title];
    
    [leble_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentView).offset(8);
   }];
   
    
    //title2
    UILabel* leble_name = [[UILabel alloc] init];
    leble_name.text = @"北京协和医院2楼心血管内科";
    leble_name.font = [UIFont boldSystemFontOfSize:15];
    leble_name.textColor = [UIColor colorWithWhite:0.8 alpha:1];
//    [leble_name sizeToFit];
    _doctor_hospital_name = leble_name;
    [self.contentView addSubview:leble_name];
    
    [leble_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(leble_title.mas_centerY);
        make.leading.equalTo(leble_title.mas_trailing).offset(8);
        
    }];
    
    //取号时间
    UILabel* leble_time = [[UILabel alloc] init];
    leble_time.text = @"取号时间:";
    [leble_time sizeToFit];
    [self.contentView addSubview:leble_time];
    
    [leble_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leble_title.mas_bottom).offset(8);
        make.leading.equalTo(self.contentView).offset(8);
    }];
   

    //时间
    //title2
    UILabel* leble_time2 = [[UILabel alloc] init];
    leble_time2.text = @"9:00-10:00";
    leble_time2.font = [UIFont boldSystemFontOfSize:15];
    leble_time2.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    [self.contentView addSubview:leble_time2];
    
    [leble_time2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leble_time.mas_top);
        make.leading.equalTo(leble_time.mas_trailing).offset(8);
    }];
//
    //取号地点
    UILabel* leble_address = [[UILabel alloc] init];
    leble_address.text = @"取号地点:";
    [leble_address sizeToFit];
    [self.contentView addSubview:leble_address];
    
    [leble_address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(leble_time.mas_bottom).offset(8);
        
        make.leading.equalTo(self.contentView).offset(8);
        
        make.bottom.equalTo(self.contentView).offset(-8);
    }];
//    //医院地址
    UIButton * btn_hosptal_name = [UIButton buttonWithType:0];
    btn_hosptal_name.titleLabel.font = [UIFont boldSystemFontOfSize:15];
    
    [btn_hosptal_name setTitle:@"北京协和医院住院部" forState:UIControlStateNormal];
   
  
    [btn_hosptal_name setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateNormal];
    [btn_hosptal_name setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0,45)];
    [btn_hosptal_name setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [btn_hosptal_name setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted ];
    
    _btn_hosptal_name = btn_hosptal_name;
    [self.contentView addSubview:btn_hosptal_name];
    
    [btn_hosptal_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(200);
        make.height.offset(20);
        make.centerY.equalTo(leble_address.mas_centerY);
        make.leading.equalTo(leble_address.mas_trailing).offset(8);
    }];
    [btn_hosptal_name addTarget:self action:@selector(clickBlock:) forControlEvents:UIControlEventTouchUpInside];
//
}
#pragma mark
#pragma mark - 点击方法
- (void)clickBlock:(UIButton*)button
{
    
    if ([self.delegate respondsToSelector:@selector(doctorAddressTableViewCell:)]) {
        [self.delegate doctorAddressTableViewCell:self];
    }
}

@end
